import {BaseModel} from "../BaseModel";

export class Lesson extends BaseModel{

    constructor(){
        super();
        this.symbolName = "Lesson";
        this.tableName = "t_lesson";
        this.id = '';//主键id
        this.name = '';//名称
        this.thumb = '';//缩略图
        this.brief = '';//简介
        this.resVersion = -1;//课程的版本号，用于判断更新
        this.chapterId = '';//关联的章节
        this.isCharged = '';//是否是付费课程(是否需要支付，0-需要；1-不需要)
        this.sortIndex = -1;//排序
        this.reverse1 = '';//备用字段1  //当前课程的版本号
        this.reverse2 = '';//备用字段2
        this.reverse3 = '';//备用字段3
    }

    dbMapper(){
        return {
            id: 'id',
            name: 'name',
            thumb: 'thumb',
            brief: 'brief',
            resVersion: 'res_version',
            chapterId: 'chapter_id',
            isCharged: 'is_charged',
            sortIndex: 'sort_index',
            reverse1: 'reverse1',
            reverse2: 'reverse2',
            reverse3: 'reverse3'
        }
    }

    /**
     * 输出转换
     * @param obj
     * @returns {Book}
     */
    mappingModel(obj){
        let lesson = new Lesson();
        lesson.id = obj.id ? obj.id : ''
        lesson.name = obj.name ? obj.name : ''
        lesson.thumb = obj.thumb ? obj.thumb : ''
        lesson.brief = obj.brief ? obj.brief : ''
        lesson.resVersion = obj.res_version ? obj.res_version : -1
        lesson.chapterId = obj.chapter_id ? obj.chapter_id : ''
        lesson.isCharged = obj.is_charged ? obj.is_charged : ''
        lesson.sortIndex = obj.sort_index ? obj.sort_index : -1
        lesson.reverse1 = obj.reverse1 ? obj.reverse1 : ''
        lesson.reverse2 = obj.reverse2 ? obj.reverse2 : ''
        lesson.reverse3 = obj.reverse3 ? obj.reverse3 : ''
        return lesson;
    }

}
